package com.example.demo.controller;

import com.example.demo.model.Blog;
import com.example.demo.service.BlogService;
import com.example.demo.util.ResponseBodyMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping( value = "/blog")
public class BlogController {

    ObjectMapper objectMapper = new ObjectMapper();
    @Autowired
    private BlogService blogService;

    @RequestMapping(value = "/load")
    public List<Blog> load() {
        return blogService.load();
    }


    @RequestMapping(value = "/getblogbyid")
    public Blog getBlogById(Integer blogId) {
        return blogService.getBlogById(blogId);
    }

}
